home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: Franz PD / Franz PD Disk #334 (1994-06)(Rhein-Sieg-Soft).zip / Franz PD Disk #334 (1994-06)(Rhein-Sieg-Soft).adf / ASo-Tools / Sources / Lupe.c < prev    next >
C/C++ Source or Header  |  1994-03-13  |  3KB  |  114 lines

  1. /* Lupe.c - vergrößert die Pixel unter dem Mousepointer */
  2.  
  3. #include <dos/dos.h>
  4. #include <intuition/intuitionbase.h>
  5. #include <intuition/intuition.h>
  6. #include <graphics/gfxmacros.h>
  7. #include <clib/exec_protos.h>
  8. #include <clib/dos_protos.h>
  9. #include <clib/graphics_protos.h>
  10. #include <clib/intuition_protos.h>
  11. #include <stdlib.h>
  12.  
  13. extern struct IntuitionBase *IntuitionBase;
  14.  
  15. #define ACTIVE_SCREEN ((struct Screen *)(IntuitionBase->ActiveScreen))
  16.  
  17. ULONG GetMessage(struct Window *win, USHORT *code)
  18. {/* MsgPort auslesen; liefert CLASS und ggf. CODE */
  19.     struct IntuiMessage *msg;
  20.     ULONG class=0;
  21.  
  22.     if(msg=(struct IntuiMessage *)GetMsg(win->UserPort))
  23.     {
  24.     class=msg->Class;
  25.     if(code) *code=msg->Code;
  26.     ReplyMsg((struct Message *)msg);
  27.     }
  28.     else if(code) *code=0;
  29.     return(class);
  30. }
  31.  
  32. #define RP_S (&ACTIVE_SCREEN->RastPort)
  33. #define XPos (ACTIVE_SCREEN->MouseX)
  34. #define YPos (ACTIVE_SCREEN->MouseY)
  35.  
  36. int _main(void)
  37. {
  38.     struct Window *win;
  39.     register struct RastPort *RP_W;
  40.     ULONG class=0;
  41.     short x0,y0,x1,y1,width=11,height=11,plusminus=4,key;
  42.     register COUNT i,j;
  43.  
  44.     if(!(win=OpenWindowTags(NULL, WA_GimmeZeroZero,TRUE,
  45.                WA_InnerWidth,(2*plusminus+1)*width+1,
  46.                WA_InnerHeight,(2*plusminus+1)*height+1,
  47.                WA_IDCMP,IDCMP_CLOSEWINDOW|IDCMP_NEWSIZE| \
  48.                 IDCMP_MOUSEMOVE|IDCMP_VANILLAKEY,
  49.                WA_ReportMouse,TRUE, WA_DragBar,TRUE,
  50.                WA_DepthGadget,TRUE, WA_SizeGadget,TRUE,
  51.                WA_SizeBBottom,TRUE, WA_CloseGadget,TRUE,
  52.                WA_Activate,TRUE, WA_Title,"Gummi-Lupe",
  53.                WA_RMBTrap,TRUE, WA_MinWidth,0, WA_MinHeight,0,
  54.                WA_MaxWidth,~0, WA_MaxHeight,~0, WA_AutoAdjust,TRUE,
  55.                WA_MouseQueue,2, TAG_DONE)))
  56.     {
  57.     Printf("kann Window nicht öffnen !\n");
  58.     return(RETURN_ERROR);
  59.     }
  60.     RP_W=win->RPort;
  61.     SetDrMd(RP_W, JAM1);
  62.     SetOPen(RP_W, 3);
  63.     while(class!=IDCMP_CLOSEWINDOW)
  64.     {
  65.     WaitPort(win->UserPort);
  66.     class=GetMessage(win,&key);
  67.     switch(class)
  68.         {
  69.         case IDCMP_VANILLAKEY:
  70.         switch(key)
  71.             {
  72.             case 27:    goto ende;  /* break; */
  73.             case 'p':   case 'P':   case '+':
  74.             ++plusminus;
  75.             goto redim;
  76.             /* break; */
  77.             case 'm':   case 'M':   case '-':
  78.             if(plusminus>1)
  79.                 {
  80.                 --plusminus;
  81.                 goto redim;
  82.                 }
  83.             /* break; */
  84.             }
  85.         break;
  86.         case IDCMP_NEWSIZE:
  87. redim:        width=(win->GZZWidth)/(2*plusminus+1);
  88.         height=(win->GZZHeight)/(2*plusminus+1);
  89.         if(width<3 || height<3) { --plusminus; goto redim; }
  90.         SetRast(RP_W,0);
  91.         case MOUSEMOVE:
  92.         x0=XPos;    y0=YPos;
  93.         for(i=-plusminus; i<=plusminus; ++i)
  94.             for(j=-plusminus; j<=plusminus; ++j)
  95.             {
  96.             SetAPen(RP_W, ReadPixel(RP_S, x0+j, y0+i));
  97.             x1=(j+plusminus)*width;
  98.             y1=(i+plusminus)*height;
  99.             RectFill(RP_W, x1,y1,x1+width,y1+height);
  100.             }
  101.         while((class=GetMessage(win,NULL))==MOUSEMOVE);
  102.         break;
  103.         }
  104.     }
  105.  
  106. ende:
  107.     CloseWindow(win);
  108.     return(RETURN_OK);
  109. }
  110.  
  111. extern void _waitwbmsg(void);
  112. void routing_that_is_never_called(void) { _waitwbmsg(); }
  113.  
  114.